package com.rockcent.third.helper;

import com.rockcent.mall.lib.domain.Channel;
import com.rockcent.mall.lib.domain.Merchant;
import com.rockcent.mall.lib.domain.enumclass.ChannelStatus;
import com.rockcent.mall.lib.helper.BaseChannelHelper;
import org.springframework.stereotype.Component;


/**
 * Created by Antinomy on 16/4/1.
 *
 */
@Component
public class ChannelHelper extends BaseChannelHelper {

    /**
     * 创建系统默认渠道
     * @param merchant
     * @param name
     * @param number
     * @return
     */
    public Channel create(Merchant merchant, String name, String number) {
        Channel channel = new Channel();
        channel.setName(name);
        channel.setNumber(number);
        channel.setFlowEstimation("未知");
        channel.setDetail("系统创建" + name);
        channel.setIntro("系统创建" + name);
        channel.setChannelTypeId(Channel.DEFAULT_CHANNEL_TYPE_ID);
        channel.setSystemDefault(true);
        channel.setChannelStatus(ChannelStatus.USING);
        channel.setMerchantId(merchant.getId());
        channel.setMallId(merchant.getMallId());
        channel.setSalesCode(this.genSalesCode());
        return channel;
    }
}
